#ifndef WGSERVER_ERRORS_H
#define WGSERVER_ERRORS_H

#include "printStackTrace.h"
#include "CrashHandler.h"
// TODO: handle errors better

// An assert isn't necessarily fatal, although if compiled with asserts enabled it will be.
#define WPAssert( EXPR ) if (!(EXPR)) { wgsAssertFailed(__FILE__,__LINE__,#EXPR); assert(EXPR); }

#define WPError( assertion, errmsg ) if( ! (assertion) ) { Log::getSingleton( ).outError( "%s:%i ERROR:\n  %s\n", __FILE__, __LINE__, (char *)errmsg ); assert( false ); }
#define WPWarning( assertion, errmsg ) if( ! (assertion) ) { Log::getSingleton( ).outError( "%s:%i WARNING:\n  %s\n", __FILE__, __LINE__, (char *)errmsg ); }

// This should always halt everything.  If you ever find yourself wanting to remove the assert( false ), switch to WPWarning or WPError
#define WPFatal( assertion, errmsg ) if( ! (assertion) ) { Log::getSingleton( ).outError( "%s:%i FATAL ERROR:\n  %s\n", __FILE__, __LINE__, (char *)errmsg ); assert( #assertion &&0 ); abort(); }

#define ASSERT WPAssert

#endif

